#include <sstream> 
#include "LiteralTable.h"

LiteralTable::LiteralTable()
{
}

LiteralTable::~LiteralTable()
{
}

int LiteralTable::insert(char cConstant) {
	//TODO optimize to remove duplicate values
	character_constants.push_back( cConstant );
	return character_constants.size() - 1;
}

int LiteralTable::insert(int nConstant) {
	//TODO optimize to remove duplicate values
	numerical_constants.push_back( nConstant );
	return numerical_constants.size()-1;
}

std::string LiteralTable::getCharacterConstants() {
	std::stringstream ss;
	ss << "\"";
	for(std::vector<char>::iterator i=character_constants.begin();
		i!=character_constants.end();
		++i)
	{
		//if(i!=character_constants.begin()) ss << ",";
		ss << (*i);
	}
	ss << "\"";
	return ss.str();
}

std::string LiteralTable::getNumericalConstants() {
	std::stringstream ss;
	for(std::vector<int>::iterator i=numerical_constants.begin();
		i!=numerical_constants.end();
		++i)
	{
		if(i!=numerical_constants.begin()) ss << ",";
		ss << (*i);
	}
	return ss.str();
}